import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入登录页面
// import Login from '@/views/Login'

Vue.use(VueRouter)

// 清空routes配置，自己配置
const routes = [
  // 需要手动输入，点击进去显示需要手动输入
  // 重定向的路径不需要家斜杠也就是path
  // {
  //   path: 'login',
  //   redirect: 'login'
  // },
  // {
  //   path: '/login',
  //   component: Login
  // },
  //  使用路由懒加载 优化性能 使用webpackChunkName减少懒加载网络请求 将名称相同的片段打包在同一个模块
  {
    path: '/',
    redirect: '/ '
  },
  {
    path: '/',
    component: () => import('@/views/Layout'),
    children: [
      {
        path: '/ ',
        component: () => import('@/views/Home')
      },
      {
        path: '/video',
        component: () => import(/* webpackChunkName:"base" */ '@/views/Video')
      },
      {
        path: '/qa',
        component: () => import(/* webpackChunkName:"base" */ '@/views/QA')
      },
      {
        path: '/profile',
        component: () => import('@/views/My')
      }
    ]
  },
  {
    path: '/login',
    // 首页面会全部打包所有文件在app.js中，所以首页面加载会非常慢，路由懒加载就啊hi需要这个页面的时候再去加载
    component: () => import('@/views/Login')
  },
  {
    path: '/search',
    component: () => import('@/views/Search')
  },
  {
    path: '/user',
    component: () => import('@/views/User')
  },
  {
    path: '/detail/:art_id',
    name: 'article',
    props: true,
    component: () => import('@/views/article')
  }
]

const router = new VueRouter({
  routes
})

export default router
